#ifndef SYMBOL_H
#define SYMBOL_H

struct Token;

#include <vector>
#include <string>
#include <map>
#include <iostream>
#include <fstream>

#include "Errors.h"

using namespace std;

struct Symbol 
{
	enum Type
	{
		Integer = 1,
		Var = 11,
		Double = 111,
		Ref = 1110,
		Unknown = 1111
	};

	Symbol()
	{
		lbp = 0;
		id = "";
        has_std = false;
		assignment = false;
	}
    
	string id;

	virtual Token* nud(Token*)
	{
		error(Error::Undefined);
		return NULL;
	}

    virtual Token* led(Token*,Token* left)
	{
		error(Error::MissingOp);
		return NULL;
	}

	virtual Token* std(Token*)
	{
		error(Error::NoStd);
		return NULL;
	}

	virtual Type type(Token* n);

	virtual string compile(Token*);
	virtual string compileDef(Token*);

    inline void error(string err)
	{
		throw id + err;
	}

	inline void warning(string err)
	{
		cout << id + err;
	}

	string toString(Type t, Token* n);
	string toCode(Type t)
	{
		switch (t)
		{
		case Integer:
			return "integer";
		case Double:
			return "double";
		case Var:
			return "var";
		case Ref:
			return "ref";
		}
		return "var";
	}

	int lbp;
    bool has_std;
	bool assignment;

};


#endif
